package capimServer;

import java.util.Collection;
import java.util.Iterator;

/**
 * A Queue of packets
 * @author danielm pessoafpc
 *
 */
public class PacketQueue {
	protected SimplePacketFormat[] queue;
	protected int start=0, end=0, size=0;

	public PacketQueue (int n){
		queue = new SimplePacketFormat[n]; 
	}
	 
	/**
	 * Add a pack at end of queue
	 * @param pack package to be added
	 * @return if the task was correctly done
	 * @throws Exception If queue was full
	 */
	public boolean add(SimplePacketFormat pack) throws Exception {
		if (size>=queue.length) throw new Exception("Full Queue");
		else { 
			queue[end] = pack;
			end = (end + 1) % queue.length;
			size++; 
		}
		return false;
	}

	
	/**
	 * Remove a pack from the queue
	 * @return the packet at most time in the queue
	 * @throws Exception Empty Queue
	 */
	public SimplePacketFormat remove() throws Exception {
		if (size<=0) throw new Exception("Empty Queue");
		else { 
			size--;
			SimplePacketFormat x = queue[start];
			start = (start + 1) % queue.length;
			return x; 
		}
	}
	
	public SimplePacketFormat element() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean offer(SimplePacketFormat e) {
		// TODO Auto-generated method stub
		return false;
	}

	public SimplePacketFormat peek() {
		// TODO Auto-generated method stub
		return null;
	}

	public SimplePacketFormat poll() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean addAll(Collection <SimplePacketFormat> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public void clear() {
		// TODO Auto-generated method stub
		
	}

	public boolean contains(SimplePacketFormat arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean containsAll(Collection<SimplePacketFormat> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean isEmpty() {
		if(size == 0) return true;
		else return false;
	}

	public Iterator<SimplePacketFormat> iterator() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean remove(SimplePacketFormat arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean removeAll(Collection<SimplePacketFormat> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean retainAll(Collection<SimplePacketFormat> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	public SimplePacketFormat[] toArray() {
		// TODO Auto-generated method stub
		return null;
	}

	public SimplePacketFormat[] toArray(SimplePacketFormat[] arg0) {
		// TODO Auto-generated method stub
		return null;
	}
}

